import { defineStore } from 'pinia'
import {
  getMerchantList,
  getProductList
} from '@/service/module/main/goods/good-sku'
import type { IOptionItem } from '@/global/types'

interface IState {
  merchantList: IOptionItem[]
  productList: IOptionItem[]
}

const useGoodSkuStore = defineStore('goodSku', {
  state: (): IState => ({
    merchantList: [],
    productList: []
  }),
  actions: {
    async getMerchantListAction(storeName: string) {
      const merchantListRes = await getMerchantList(storeName)
      this.merchantList = merchantListRes.data
    },
    async getProductListAction(merchantId: number, storeName: string) {
      const productListRes = await getProductList(merchantId, storeName)
      this.productList = productListRes.data
    }
  }
})

export default useGoodSkuStore
